<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/portals/resources/open-blank-host.js"></script>
<body>
  <script>
    async function createPortal(doc, src) {
      var portal = doc.createElement("portal");
      portal.src = new URL(src, location.href);
      doc.body.appendChild(portal);
      await new Promise(r => portal.onload = r);
      return portal;
    }

    promise_test(async () => {
      var w = await openBlankPortalHost();
      var doc = w.document;
      var portal = await createPortal(doc,
          "resources/portals-create-orphaned-portal.html",
          "create-orphaned-portal");
      portal.activate();
      await createPortal(doc, "resources/simple-portal.html");
    }, "creating a portal from an orphaned portal should succeed");
  </script>
</body>
